package com.xbongbong.saas.script.tempenum;

import com.alibaba.fastjson.JSONObject;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.DefaultTypeEnum;
import com.xbongbong.paas.enums.DefaultValueEnum;
import com.xbongbong.paas.help.FormDataFormExplainHelper;
import com.xbongbong.paas.field.DefaultAttrPoJo;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.FormulaPoJo;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.NumericalLimitsPoJo;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.RefundStatusEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.ForbiddenSettingEnum;
import com.xbongbong.saas.enums.RedundantTemplateTypeEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;

import com.xbongbong.saas.enums.business.ReturnEnum;
import com.xbongbong.saas.enums.dictionary.AllInBoundEnum;
import com.xbongbong.saas.enums.dictionary.DrawbackStatusEnum;
import com.xbongbong.saas.enums.dictionary.RefundReasonEnum;
import com.xbongbong.saas.enums.dictionary.ReturnStatusEnum;
import com.xbongbong.saas.enums.dictionary.ReturnTypeEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import com.xbongbong.sys.enums.RoleEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * 退货单初始化枚举
 *
 * @author wujian
 * @version v1.0
 * @date 2020/12/23 20:16
 * @since v1.0
 */
@Getter
public enum TempRefundDistributorEnum {

    //刷脚本专用枚举
    BASE_INFO(ReturnEnum.BASE_INFO),
    RETURN_NO(ReturnEnum.RETURN_NO),
    LINK_DISTRIBUTOR(ReturnEnum.LINK_DISTRIBUTOR),
    ORDER_ID(ReturnEnum.ORDER_ID),
    RETURN_NAME(ReturnEnum.RETURN_NAME),
    SIGN_USER(ReturnEnum.SIGN_USER),
    SIGN_DATE(ReturnEnum.SIGN_DATE),
    OWNER_ID(ReturnEnum.OWNER_ID),
    COUSERID(ReturnEnum.COUSERID),

    RETURN_INFO(ReturnEnum.RETURN_INFO),
    PRODUCTS(ReturnEnum.PRODUCTS),
    RETURN_TIPS(ReturnEnum.RETURN_TIPS),
    RETURN_AMOUNT(ReturnEnum.RETURN_AMOUNT),
    REFUND_REASON(ReturnEnum.REFUND_REASON),
    ORDER_STATUS(ReturnEnum.ORDER_STATUS),
    REFUND_STATUS(ReturnEnum.REFUND_STATUS),
//    DRAWBACK_STATUS(ReturnEnum.DRAWBACK_STATUS),
    REFUND_TYPE(ReturnEnum.REFUND_TYPE),

    MEMO(ReturnEnum.MEMO),
    IMAGE(ReturnEnum.IMAGE),

    REFUND_INFO(ReturnEnum.REFUND_INFO),
    PAYMENT_SHEETS(ReturnEnum.PAYMENT_SHEETS),
    REFUND_AMOUNT(ReturnEnum.REFUND_AMOUNT),
    INVOICES(ReturnEnum.INVOICES),
    PAYMENTS(ReturnEnum.PAYMENTS),

    SYSTEM_INFO(ReturnEnum.SYSTEM_INFO),
    ORDERER_ID(ReturnEnum.ORDERER_ID),
    ORDERER(ReturnEnum.ORDERER),
    CREATOR_ID(ReturnEnum.CREATOR_ID),
    ADD_TIME(ReturnEnum.ADD_TIME),
    UPDATE_TIME(ReturnEnum.UPDATE_TIME),

    RED_CONTRACT_ID(ReturnEnum.RED_CONTRACT_ID),
    LINK_DISTRIBUTOR_LINKED_TEXT(ReturnEnum.LINK_DISTRIBUTOR_LINKED_TEXT),
    ORDER_ID_LINKED_TEXT(ReturnEnum.ORDER_ID_LINKED_TEXT),
    PAYMENT_SHEETS_LINKED_TEXT(ReturnEnum.PAYMENT_SHEETS_LINKED_TEXT),
    INVOICES_LINKED_TEXT(ReturnEnum.INVOICES_LINKED_TEXT),
    PAYMENTS_LINKED_TEXT(ReturnEnum.PAYMENTS_LINKED_TEXT),
    INSTOCK_ID(ReturnEnum.INSTOCK_ID),
    ALL_IN_BOUND(ReturnEnum.ALL_IN_BOUND),;

    private ReturnEnum anEnum;

    TempRefundDistributorEnum(ReturnEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempRefundDistributorEnum> getAllEnum() {
        List<TempRefundDistributorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }


    /**
     * 初始化编号
     *
     * @param fieldAttrEntity 属性
     */
    public static void initReturnNo(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.REFUND.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.REFUND.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(RETURN_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(1);
        fieldAttrEntity.setSerialNumber(InitExplainsHelper.setSerialNumber(SerialNumberEnum.RETURN_NO));
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initReturnName(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.REFUND.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.REFUND.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(RETURN_NAME.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
    }

    /**
     * 初始化退货原因
     *
     * @param fieldAttrEntity 属性
     */
    public static void initRefundReason(FieldAttrEntity fieldAttrEntity) {
//        String str = "产品损坏,质量问题,发错产品,其他原因";
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(RefundReasonEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(1);
    }

    public static void initLinkDistributor(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CUSTOMER.getCode());
        fieldAttrEntity.setLinkedText(LINK_DISTRIBUTOR_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("base");
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(LINK_DISTRIBUTOR.getAnEnum().getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initOrderId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setLinkedText(ORDER_ID_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyMode(XbbRefTypeEnum.CONTRACT.getAlias());
        saasParticularAttributePoJo.setRelyType("base");
        saasParticularAttributePoJo.setRelyAttr(LINK_DISTRIBUTOR.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDistributorMark(1);

    }

    public static void initProducts(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PRODUCT.getCode());
        fieldAttrEntity.setLinkedText(LINK_DISTRIBUTOR_LINKED_TEXT.anEnum.getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyMode(XbbRefTypeEnum.CONTRACT.getAlias());
        saasParticularAttributePoJo.setRelyType("relied");
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }

    public static void initPaymentSheets(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PAYMENT_SHEET.getCode());
        fieldAttrEntity.setLinkedText(PAYMENT_SHEETS_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyAttr(ORDER_ID.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    public static void initInvoices(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.INVOICE.getCode());
        fieldAttrEntity.setLinkedText(INVOICES_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyAttr(ORDER_ID.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    public static void initPayments(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PAYMENT.getCode());
        fieldAttrEntity.setLinkedText(PAYMENTS_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyAttr(ORDER_ID.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    public static void initRefundAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(BasicConstant.ZERO);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
    }

    public static void initReturnAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        FormulaPoJo formulaInfo = new FormulaPoJo();
        String formula = "SUM({self." + ReturnEnum.PRODUCTS.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr() + "})";
        JSONObject labelMap = new JSONObject();
        labelMap.put("self." + ReturnEnum.PRODUCTS.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr(), "关联产品.单价小计");
        formulaInfo.setFormula(formula);
        formulaInfo.setLabelMap(labelMap);
        defaultAttrPoJo.setDefaultType("formula");
        defaultAttrPoJo.setFormulaInfo(formulaInfo);
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        // 合同金额默认限定 0 ~ 100000000000
        NumericalLimitsPoJo numericalLimits = new NumericalLimitsPoJo();
        numericalLimits.setMin(0D);
        numericalLimits.setMax(100000000000D);
        fieldAttrEntity.setNumericalLimits(numericalLimits);
        fieldAttrEntity.setNumericalLimitsFlag(1);
        fieldAttrEntity.setShowEditable(1);
    }

    /**
     * 初始化签订时间
     * @param fieldAttrEntity
     */
    public static void initSignDate(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDateType("yyyy-MM-dd");
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType(DefaultTypeEnum.TODAY.getAlias());
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
    }

    /**
     * 初始化签订人
     * @param fieldAttrEntity
     */
    public static void initSignUser(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(SIGN_USER.getAnEnum().getAttr());
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType(DefaultTypeEnum.DYNAMIC.getAlias());
        defaultAttrPoJo.setDefaultValue(DefaultValueEnum.LOGIN_USER.getValue());
        defaultAttrPoJo.setDefaultList(new ArrayList<>());
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
    }

    public static void initCoUserId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setRequired(0);
        //可新增权限：默认【超级管理员、销售主管、创建人、负责人、负责人主管】可新增协同人，支持自定义；
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setAdd(1);
        fieldAttrEntity.setAddAdvanceEnable(1);
        fieldAttrEntity.setShowAdd(1);
        //可删除权限：默认【超级管理员、销售主管、负责人、负责人主管】可删除协同人，支持自定义；
        fieldAttrEntity.setRemove(1);
        fieldAttrEntity.setRemoveAdvanceEnable(1);
        fieldAttrEntity.setShowRemove(1);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setUnableEditMemo(null);
        fieldAttrEntity.setAddRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.MANAGER));
        fieldAttrEntity.setRemoveRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.MANAGER));
    }
    public static void initOwnerId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setRequired(1);
        //可新增权限：默认【超级管理员、销售主管、创建人、负责人、负责人主管】可新增负责人，支持自定义；
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setAdd(1);
        fieldAttrEntity.setAddAdvanceEnable(1);
        fieldAttrEntity.setShowAdd(1);
        fieldAttrEntity.setRemove(1);
        fieldAttrEntity.setRemoveAdvanceEnable(1);
        fieldAttrEntity.setShowRemove(1);
        fieldAttrEntity.setMultiple(1);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setUnableEditMemo(null);
        fieldAttrEntity.setAddRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.MANAGER));
        fieldAttrEntity.setRemoveRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.MANAGER));
    }
    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }

    public static void initAllInBound(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(AllInBoundEnum.class, fieldAttrEntity.getFieldType()));
    }

    public static void initReturnStatus(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsDictionary(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setEditable(0);
        List<ItemPoJo> itemPoJos = InitExplainsHelper.setCombItemByEnum(RefundStatusEnum.class, fieldAttrEntity.getFieldType());
        List<String> shipStatusCodeList = Arrays.asList(RefundStatusEnum.UNREFUND.getName(), RefundStatusEnum.PARTIAL.getName(), RefundStatusEnum.REFUND.getName(), RefundStatusEnum.CLOSED.getName());
        for (ItemPoJo itemPoJo: itemPoJos) {
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            if (!shipStatusCodeList.contains(itemPoJo.getText())) {
                itemPoJo.setShowType(ShowTypeEnum.NONE.getCode());
                itemPoJo.setEditHide(1);
            } else {
                if (Objects.equals(itemPoJo.getText(), RefundStatusEnum.UNREFUND.getName())) {
                    itemPoJo.setChecked(true);
                }
            }
        }
        List<String> settingList = Arrays.asList(ForbiddenSettingEnum.DISABLE_OPTION_RELY.getAlias(), ForbiddenSettingEnum.DISABLE_SELF_DEFINE.getAlias());
        fieldAttrEntity.setForbiddenSettingList(settingList);
        fieldAttrEntity.setItemBanDefault(1);
        fieldAttrEntity.setItems(itemPoJos);
    }

    public static void initDrawbackStatus(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsDictionary(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setEditable(0);
        List<ItemPoJo> itemPoJos = InitExplainsHelper.setCombItemByEnum(DrawbackStatusEnum.class, fieldAttrEntity.getFieldType());
        List<String> drawbackStatusCodeList = Arrays.asList(DrawbackStatusEnum.NO_REFUND.getName(), DrawbackStatusEnum.PART_REFUND.getName(), DrawbackStatusEnum.ALREADY_REFUND.getName());
        for (ItemPoJo itemPoJo: itemPoJos) {
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            if (!drawbackStatusCodeList.contains(itemPoJo.getText())) {
                itemPoJo.setShowType(ShowTypeEnum.NONE.getCode());
                itemPoJo.setEditHide(1);
            }
        }
        List<String> settingList = Arrays.asList(ForbiddenSettingEnum.DISABLE_OPTION_RELY.getAlias(), ForbiddenSettingEnum.DISABLE_SELF_DEFINE.getAlias());
        fieldAttrEntity.setForbiddenSettingList(settingList);
        fieldAttrEntity.setItemBanDefault(1);
        fieldAttrEntity.setItems(itemPoJos);
    }

    public static void initRefundType(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsDictionary(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setEditable(0);
        List<ItemPoJo> itemPoJos = InitExplainsHelper.setCombItemByEnum(ReturnTypeEnum.class, fieldAttrEntity.getFieldType());
        List<String> refundTypeCodeList = Arrays.asList(ReturnTypeEnum.AUTONOMOUS_RETURN.getName(), ReturnTypeEnum.VALET_RETRUN.getName());
        for (ItemPoJo itemPoJo: itemPoJos) {
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            if (!refundTypeCodeList.contains(itemPoJo.getText())) {
                itemPoJo.setShowType(ShowTypeEnum.NONE.getCode());
                itemPoJo.setEditHide(1);
            }
        }
        List<String> settingList = Arrays.asList(ForbiddenSettingEnum.DISABLE_OPTION_RELY.getAlias(), ForbiddenSettingEnum.DISABLE_SELF_DEFINE.getAlias());
        fieldAttrEntity.setForbiddenSettingList(settingList);
        fieldAttrEntity.setItemBanDefault(1);
        fieldAttrEntity.setItems(itemPoJos);
    }

    public static void initOrderStatus(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsDictionary(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setEditable(0);
        List<ItemPoJo> itemPoJos = InitExplainsHelper.setCombItemByEnum(ReturnStatusEnum.class, fieldAttrEntity.getFieldType());
        List<String> refundTypeCodeList = Arrays.asList(ReturnStatusEnum.UNDER_REVIEW.getName(), ReturnStatusEnum.ABOLISHED.getName(),ReturnStatusEnum.PROCESSING.getName(), ReturnStatusEnum.COMPLETED.getName(),ReturnStatusEnum.CLOSED.getName());
        for (ItemPoJo itemPoJo: itemPoJos) {
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            if (!refundTypeCodeList.contains(itemPoJo.getText())) {
                itemPoJo.setShowType(ShowTypeEnum.NONE.getCode());
                itemPoJo.setEditHide(1);
            }
        }
        List<String> settingList = Arrays.asList(ForbiddenSettingEnum.DISABLE_OPTION_RELY.getAlias(), ForbiddenSettingEnum.DISABLE_SELF_DEFINE.getAlias());
        fieldAttrEntity.setForbiddenSettingList(settingList);
        fieldAttrEntity.setItemBanDefault(1);
        fieldAttrEntity.setItems(itemPoJos);
    }

}

